package com.ruanmou.vip.rabbitmq.demo.helloworld;

import com.rabbitmq.client.Channel;
import com.ruanmou.vip.rabbitmq.demo.util.RabbitMQUtil;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * 欢迎同学们来到牧码人教育
 *
 * @Classname Producer
 * @Description TODO
 * @Date 2020-3-7 10:49
 * @Created by Gerry
 */
public class Producer {

    public static void main(String[] args) throws IOException, TimeoutException {
        // 创建Channel
        Channel channel = RabbitMQUtil.getConnection().createChannel();
        // 定义一个队列
        channel.queueDeclare("hello_queue",false,false,false,null);
        // 发送消息
        channel.basicPublish("","hello_queue", null,"Hello RabbitMQ!!!".getBytes());
        System.out.println("消息发送成功");
        channel.close();
    }
}
